<?php
/**
 * 控制器：视图
 */
namespace app\controller;

use app\BaseController;
use think\facade\Log;
use think\facade\View;
class Index extends BaseController
{
    //首页
    public function index()
    {
        $list = [
            [
                'name'=>'test1',
                'phone'=>'188',
            ],
            [
                'name'=>'test2',
                'phone'=>'168',
            ],
            [
                'name'=>'test3',
                'phone'=>'138',
            ],
        ];

        return view('index',[
            'text'=>'这是参数',
            'list'=>$list,
        ]);
        // return '<style>*{ padding: 0; margin: 0; }</style><iframe src="https://www.thinkphp.cn/welcome?version=' . \think\facade\App::version() . '" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>';
    }

    //路由和控制器
    public function routeAndController($id = '1')
    {
        $name = request()->param('name');
        return view('routeAndController',[
            'id'=>$id,
            'name'=>$name,
        ]);
    }

    //数据库
    public function database()
    {
        return view('database');
    }

    //模型
    public function model()
    {
        return view('model');
    }

    //错误和日志
    public function log()
    {
        $text = [
            'name'=>'ye',
            'age'=>18
        ];
        Log::record('测试日志信息','warning');//设置级别
        Log::record($text);//json对象
        trace($text);//助手函数

        
        return view('log');
    }

    //php信息
    public function info()
    {
        return view('info');
    }

    public function hello($name = 'ThinkPHP8')
    {
        return 'hello,' . $name;
    }
    
    //404
    public function miss()
    {
        return view('404');
    }
    



    


}
